package com.yanqu.road.server.cross3server.cmd.server;

import com.yanqu.road.logic.xlogic.server.XServerNameMap;
import com.yanqu.road.pb.cross3.server.CrossChannelServerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.cross3server.manager.Cross3XServerNameMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Cross3Protocol;

@Cmd(code = Cross3Protocol.C3_SYNC_SERVER_NAME_FROM_CHANNEL, desc = "跨地区服务器同步区服名称")
public class SyncServerNameFromChannelCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        XServerNameMap serverNameMap = Cross3XServerNameMgr.getServerNameMap();
        CrossChannelServerProto.ServerNameListMsg reqMsg = CrossChannelServerProto.ServerNameListMsg.parseFrom(packet.getBytes());
        for (CrossChannelServerProto.ServerNameMsg msg : reqMsg.getNameListList()) {
            serverNameMap.addServerName(msg.getChannelId(), msg.getServerId(), msg.getServerName());
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
